package design.pattern.状态模式;

/**
 * 环境类:模拟一天24小时状态
 * [9 - 12]：精神满满工作
 * (12 - 13):吃饭
 * [13 - 18]: 无精打采的工作
 * 剩下的时间：自由时间，无拘无束
 *
 */
public class Context {
    private int hour; //时间

    private State state = new FreeState(); //状态,初始化为自由时间状态

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public State getState() {
        return state;
    }

    public Context setState(State state) {
        this.state = state;
        return this;
    }

    public void request(){
        state.handle(this);
    }
}
